from queue import Queue
from threading import Thread
q=Queue()
q.put(0)

def work1():
    for i in range(1000000):
        a=q.get()
        a+=1
        q.put(a)


def work2():
    for i in range(1000000):
        a=q.get()
        a+=1
        q.put(a)


if __name__ == '__main__':
    t1 = Thread(target=work1)
    t1.start()
    t2 = Thread(target=work2)
    t2.start()
    t1.join()
    t2.join()
    print('主线程---全局a：', q.get())